import xlrd
import pyecharts.options as opts
data=xlrd.open_workbook(r'C:\Users\chumenliuxiang\Desktop\实验室作业\作业.xls','r')
sheet_num=data.nsheets
# print(sheet_num)
biao1=data.sheet_by_name('Sheet1')
# print(biao1)
yuce=biao1.col_values(0)
shiji=biao1.col_values(1)
yuce=yuce[1:]
shiji=shiji[1:]
# print(yuce)


import pyecharts.options as opts
from pyecharts.charts import Line
x_data = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]


(
    Line()
    .add_xaxis(xaxis_data=range(1,41))
    .add_yaxis(
        series_name="预测值",
        y_axis=yuce,
        label_opts=opts.LabelOpts(is_show=False),
    )
    .add_yaxis(
        series_name="实际值",
        y_axis=shiji,
        label_opts=opts.LabelOpts(is_show=False),
    )
    .set_global_opts(
        title_opts=opts.TitleOpts(title="预测实际对比"),
        tooltip_opts=opts.TooltipOpts(trigger="axis"),
        yaxis_opts=opts.AxisOpts(
            type_="value",
            axistick_opts=opts.AxisTickOpts(is_show=True),
            splitline_opts=opts.SplitLineOpts(is_show=True),
        ),
        xaxis_opts=opts.AxisOpts(type_="category", boundary_gap=False),
    )
    .render("stacked_line_chart.html")
)